import junit.framework.TestCase;


public class LiczbaTest extends TestCase {

	private Liczba x = null;
	
	protected void setUp() throws Exception {
		x = new Liczba("21",10);
	}
	
	public void testCorrectness () {
		String str ="";
		try {
			str = x.zapis(2);
		} 
		catch (LiczbaException e) {
			e.printStackTrace();
		}
		assertEquals("Not correct: ","10101",str);
	}
	
	public void testNotNull () {
		
		try {
			assertNotNull("Null returned: ",x.zapis(2));
		} 
		catch (LiczbaException e) {
			e.printStackTrace();
		}
	}
	
	public void testNotSame () {
		try {
			assertNotSame("Same: ",x.zapis(2),x.zapis(2));
		} 
		catch (LiczbaException e) {
			e.printStackTrace();
		}
	}
	
	public void testCorrectness2 () {
		try {
			assertTrue("Not equal after reversing", Integer.parseInt(x.zapis(2),2) == 21);
		}
		catch(NumberFormatException e) {
			e.printStackTrace();
		}
		catch (LiczbaException e) {
			e.printStackTrace();
		}
	}
	
	public void testCorrectness3 () {
		try {
			assertFalse("Wrong length", x.zapis(2).length()!=5);
		}
		catch(NumberFormatException e) {
			e.printStackTrace();
		}
		catch (LiczbaException e) {
			e.printStackTrace();
		}
	}	
	
	protected void tearDown() throws Exception {
		x = null;
	}

}
